<template>
  <div class="common-layout">
    <el-container>
      <el-header class="header"> 宏烨找房后台管理系统 </el-header>
      <el-container>
        <el-aside width="200px" class="cebox">
          <el-menu
            router
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            :default-active="gl"
            text-color="#fff"
            @open="handleOpen"
            @close="handleClose"
          >
            <div class="rulebox">管理员</div>
            <el-menu-item v-for="item in childroute" :key="item.path" :index="item.path">
              <el-icon v-if="item.icon">
                <component :is="item.icon"></component>
              </el-icon>
              <span>{{ item.title }}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <RouterView></RouterView>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue";
import { RouterLink, RouterView, useRouter } from "vue-router";
import { childroute } from "../../router/index";

import { Document, Menu as IconMenu, Location, Setting } from "@element-plus/icons-vue";

const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const ben = JSON.parse(localStorage.getItem("ben"));
console.log(ben);

const gl = ref(ben);
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
  localStorage.setItem("ben", JSON.stringify(key));
  gl.value = key;
};
</script>

<style scoped lang="scss">
.cebox {
  height: calc(100vh - 60px);
}
.el-menu-vertical-demo {
  height: 100%;
}

.header {
  background: #4381e6;
  width: 100%;
  height: 60px;
  line-height: 60px;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}
.rulebox {
  width: 100%;
  height: 60px;
  line-height: 60px;
  text-align: center;
  color: #fff;
}
</style>
